<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - RadioField Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset/reset-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">

 </head>

 <body>

<p class='demoTitle'>inputEx - RadioField Usage</p>


<!-- Example 1 -->
<div class='exampleDiv'>

	<p class="title">Basic RadioField creation</p>
	
	<p>Use the following code to create a basic inputEx RadioField.</p>

	<div class='demoContainer' id='container1'></div>

	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			new YAHOO.inputEx.RadioField({label: 'Where did you learn about inputEx ?', name: 'example1', choices: ['Ajaxian','YUI blog','other'], parentEl: 'container1'});
		</textarea>
	</div>

</div>

<!-- Example 2 -->
<div class='exampleDiv'>

	<p class="title">allowAny option</p>
	
	<p>The "allowAny" option adds a radio associated to a StringField to let the user enter any value.</p>

	<div class='demoContainer' id='container2'></div>

	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			var field2 = new YAHOO.inputEx.RadioField({label: 'Where did you learn about inputEx ?', name: 'example2', choices: ['Ajaxian','YUI blog'], parentEl: 'container2', allowAny: true});
			field2.updatedEvt.subscribe(function(e, params) {
					YAHOO.util.Dom.get('container2').appendChild( YAHOO.inputEx.cn('div',null,null, "Updated with value: "+params[0]) );
			});
		</textarea>
	</div>

</div>

<!-- Example 3 -->
<div class='exampleDiv'>

	<p class="title">Styling RadioField</p>
	
	<p>Display the choices vertically. (add an id to the field and set "float" style to "none")</p>

	<style>
	#verticalChoiceField div.inputEx-RadioField-choice {
		float: none;
	}
	</style>
	<div class='demoContainer' id='container3'></div>

	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			new YAHOO.inputEx.RadioField({label: 'Where did you learn about inputEx ?', name: 'example3', choices: ['Ajaxian','YUI blog','other'], parentEl: 'container3', id: 'verticalChoiceField'});
			
			/* Style */
			#verticalChoiceField div.inputEx-RadioField-choice {
				float: none;
			}
		</textarea>
	</div>

</div>

<!-- Example 4 -->
<div class='exampleDiv'>

	<p class="title">Test more options</p>
	
	<p>Values different from choices, required field, etc...</p>

	<div class='demoContainer' id='container4'></div>

	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			var field4 = new YAHOO.inputEx.RadioField({label: "What's your favorite programming language ?", name: 'example4', choices: ['Ruby','C#',"PHP"], values: ['ruby','c_sharp','php'],  allowAny: true, parentEl: 'container4', showMsg:true, required:true});
			field4.updatedEvt.subscribe(function(e, params) {
					YAHOO.util.Dom.get('container4').appendChild( YAHOO.inputEx.cn('div',null,null, "Updated with value: "+params[0]) );
			});

			var exampleDiv = YAHOO.util.Dom.get('container4');

			var button1 = inputEx.cn('button', null, null, 'setValue()');
			exampleDiv.appendChild(button1); 
			YAHOO.util.Event.addListener(button1, 'click', function() { field4.setValue("Javascript"); });

			var button2 = inputEx.cn('button', null, null, 'getValue()');
			exampleDiv.appendChild(button2); 
			YAHOO.util.Event.addListener(button2, 'click', function() { alert(field4.getValue()); });
		</textarea>
	</div>

</div>


<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/yahoo/yahoo-min.js"></script> 
<script type="text/javascript" src="../lib/yui/dom/dom-min.js"></script> 
<script type="text/javascript" src="../lib/yui/event/event-min.js"></script>

<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/fields/StringField.js"  type='text/javascript'></script>
<script src="../js/fields/RadioField.js"  type='text/javascript'></script>

<script>

YAHOO.util.Event.addListener(window, 'load', function() {

	
	try {

	// Example 1
	new YAHOO.inputEx.RadioField({label: 'Where did you learn about inputEx ?', name: 'example1', choices: ['Ajaxian','YUI blog','other'], parentEl: 'container1'});
	
	// Example 2
	var field2 = new YAHOO.inputEx.RadioField({label: 'Where did you learn about inputEx ?', name: 'example2', choices: ['Ajaxian','YUI blog'], parentEl: 'container2', allowAny: true});
	field2.updatedEvt.subscribe(function(e, params) {
			YAHOO.util.Dom.get('container2').appendChild( YAHOO.inputEx.cn('div',null,null, "Updated with value: "+params[0]) );
	});
	
	// Example 3
	new YAHOO.inputEx.RadioField({label: 'Where did you learn about inputEx ?', name: 'example3', choices: ['Ajaxian','YUI blog','other'], parentEl: 'container3', id: 'verticalChoiceField'});
	
	// Example 4
	var field4 = new YAHOO.inputEx.RadioField({label: "What's your favorite programming language ?", name: 'example4', choices: ['Ruby','C#',"PHP"], values: ['ruby','c_sharp','php'],  allowAny: true, parentEl: 'container4', showMsg:true, required:true});
	field4.updatedEvt.subscribe(function(e, params) {
			YAHOO.util.Dom.get('container4').appendChild( YAHOO.inputEx.cn('div',null,null, "Updated with value: "+params[0]) );
	});
	
	var exampleDiv = YAHOO.util.Dom.get('container4');
	
	var button1 = inputEx.cn('button', null, null, 'setValue()');
	exampleDiv.appendChild(button1); 
	YAHOO.util.Event.addListener(button1, 'click', function() { field4.setValue("Javascript"); });
	
	var button2 = inputEx.cn('button', null, null, 'getValue()');
	exampleDiv.appendChild(button2); 
	YAHOO.util.Event.addListener(button2, 'click', function() { alert(field4.getValue()); });
	
	
	
	} catch(ex) {console.log(ex);}
});

</script>

<script src="js/dpSyntaxHighlighter.js"></script>
<script language="javascript"> 
dp.SyntaxHighlighter.HighlightAll('code');
</script>

 </body>
</html>